#ifndef MAPWIDGET_H
#define MAPWIDGET_H

#include <QWidget>
#include <QTimer>
#include "map.h"

class MapWidget : public QWidget {
    Q_OBJECT
public:
    Map map;
    double zoomLevel = 0;
    double centerX = 500;
    double centerY = 500;

    int dashOffset = 0;
    QTimer* dashTimer = nullptr;

    explicit MapWidget(QWidget *parent = nullptr);
    void generateNewMap(int numVertex = 1000); // 默认生成较少的顶点便于显示

protected:

    void paintEvent(QPaintEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

private:

    double bgScale = 1.0;
    QPointF bgOffset;
    QPoint lastDragPos;
    bool isDragging = false;

    QPointF mapToScene(const QPointF &screenPos) const;
signals:
    void mapGenerationComplete(); // 新增信号

};
#endif // MAPWIDGET_H
